package com.zut.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zut.mapper.ParentsMapper;
import com.zut.pojo.Parents;
import com.zut.pojo.Teacher;
import com.zut.service.ParentsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author parents
 * @since 2021-05-31
 */
@Service
public class ParentsServiceImpl extends ServiceImpl<ParentsMapper, Parents> implements ParentsService {

    @Resource
    private ParentsService parentsService;

    @Resource
    private ParentsMapper parentsMapper;
    //修改家长信息
    @Override
    public void updateParents(String parname, String parpwd, String stuname, String stusex, int stuage, int parhour, String parphone) {
        parentsService.updateParents(parname,parpwd,stuname,stusex,stuage,parhour,parphone);
    }

    //展示所有家长信息
    @Override
    public List<Parents> selectAllParents() {
        List<Parents> list = parentsMapper.selectList(null);
        return list;
    }

    //按用户名查询家长信息
    @Override
    public Parents selectParentsByName(String parname) {
        QueryWrapper<Parents> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parname", parname);
        Parents parents = parentsMapper.selectOne(queryWrapper);
        return parents;
    }

    //按id查询家长信息
    @Override
    public Parents selectParentsById(Integer parid) {
        QueryWrapper<Parents> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("parid", parid);
        Parents parents = parentsMapper.selectOne(queryWrapper);
        return parents;
    }


    //管理⚪模糊查询
    @Override
    public List<Parents> seapar(String msg) {
        QueryWrapper<Parents> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("parid", msg).or().like("parname",msg)
        .or().like("stuname",msg)
        .or().like("stusex",msg)
        .or().like("stuage",msg)
        .or().like("parhour",msg)
        .or().like("parphone",msg)
        ;
        List<Parents> parentsList = parentsMapper.selectList(queryWrapper);
        return parentsList;
    }
}

